<?php
include  'loginCheck.php';
include  'Util.php';

$link = Util::getLink();


$query = sprintf(Util::$insert_jornakText,
    mysql_real_escape_string($_POST['element_1']),
    mysql_real_escape_string($_POST['element_2']),
    mysql_real_escape_string(null),
    mysql_real_escape_string(null),
    mysql_real_escape_string(null),
    mysql_real_escape_string(null)
);

// Perform Query
$result = mysql_query($query);

// Check result
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}
//echo ("First query succesful. <br>");

// Zapis do destination
$query = sprintf(Util::$insert_jornakDestination,
    mysql_real_escape_string($_POST['form_type']),
    mysql_real_escape_string(mysql_insert_id()),
    //2011-04-11 16:01:31
    mysql_real_escape_string(date('Y-m-d H:i:s'))
);

// Perform Query
$result = mysql_query($query);

// Check result
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}
//echo ("Second query succesful. <br>");

Util::closeLink($link);

header("location: ".Constants::$link_done_fromResolve);
        ?>
